<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台管理系统 Layout</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f7fa;
            color: #333;
            height: 100vh;
            overflow: hidden;
        }

        /* 主布局容器 */
        .layout-container {
            display: flex;
            height: 100vh;
            transition: all 0.3s ease;
        }

        /* 侧边栏样式 */
        .sidebar {
            width: 220px;
            background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
            color: white;
            height: 100vh;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
            display: flex;
            flex-direction: column;
            z-index: 100;
        }

        /* 折叠状态下的侧边栏 */
        .sidebar.collapsed {
            width: 64px;
        }

        /* 侧边栏头部 */
        .sidebar-header {
            padding: 20px 15px;
            display: flex;
            align-items: center;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            transition: all 0.3s ease;
        }

        .sidebar.collapsed .sidebar-header {
            justify-content: center;
            padding: 20px 0;
        }

        .logo {
            width: 32px;
            height: 32px;
            background: linear-gradient(45deg, #3498db, #9b59b6);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 12px;
            font-weight: bold;
            font-size: 16px;
        }

        .logo-text {
            font-size: 18px;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            transition: opacity 0.3s ease;
        }

        .sidebar.collapsed .logo-text {
            opacity: 0;
            width: 0;
            margin-right: 0;
        }

        /* 折叠按钮 */
        .toggle-btn {
            background: rgba(255, 255, 255, 0.1);
            border: none;
            color: white;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
            margin-left: auto;
        }

        .toggle-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: rotate(180deg);
        }

        /* 菜单列表 */
        .menu-list {
            flex: 1;
            overflow-y: auto;
            padding: 15px 0;
        }

        .menu-item {
            display: flex;
            align-items: center;
            padding: 12px 20px;
            cursor: pointer;
            transition: all 0.2s ease;
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
        }

        .menu-item:hover {
            background: rgba(255, 255, 255, 0.1);
            color: white;
        }

        .menu-item.active {
            background: rgba(52, 152, 219, 0.3);
            color: white;
            border-left: 3px solid #3498db;
        }

        .menu-icon {
            width: 20px;
            text-align: center;
            margin-right: 15px;
            font-size: 16px;
            transition: all 0.3s ease;
        }

        .menu-text {
            white-space: nowrap;
            overflow: hidden;
            transition: opacity 0.3s ease;
        }

        .sidebar.collapsed .menu-text {
            opacity: 0;
            width: 0;
            margin-right: 0;
        }

        .sidebar.collapsed .menu-item {
            justify-content: center;
            padding: 15px 0;
        }

        .sidebar.collapsed .menu-icon {
            margin-right: 0;
        }

        /* 主内容区域 */
        .main-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            height: 100vh;
            transition: all 0.3s ease;
        }

        /* 头部区域 */
        .header {
            height: 60px;
            background: white;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            display: flex;
            align-items: center;
            padding: 0 24px;
            z-index: 99;
        }

        .breadcrumb {
            flex: 1;
            display: flex;
            align-items: center;
            color: #666;
            font-size: 14px;
        }

        .breadcrumb-item {
            margin-right: 8px;
        }

        .breadcrumb-item:not(:last-child)::after {
            content: '/';
            margin-left: 8px;
            color: #ccc;
        }

        .header-actions {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .action-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: #f8f9fa;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #666;
            transition: all 0.3s ease;
        }

        .action-btn:hover {
            background: #e9ecef;
            color: #333;
            transform: translateY(-2px);
        }

        /* 内容区域 */
        .content {
            flex: 1;
            padding: 24px;
            overflow-y: auto;
            background: #f5f7fa;
        }

        .content-title {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 24px;
            color: #2c3e50;
        }

        .card {
            background: white;
            border-radius: 12px;
            padding: 24px;
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
            margin-bottom: 24px;
        }

        .card-title {
            font-size: 18px;
            font-weight: 600;
            margin-bottom: 16px;
            color: #2c3e50;
        }

        /* 抽屉样式 */
        .drawer-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .drawer-overlay.open {
            opacity: 1;
            visibility: visible;
        }

        .drawer {
            position: fixed;
            top: 0;
            right: 0;
            width: 320px;
            height: 100vh;
            background: white;
            box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
            transform: translateX(100%);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 1001;
            display: flex;
            flex-direction: column;
        }

        .drawer-overlay.open .drawer {
            transform: translateX(0);
        }

        .drawer-header {
            padding: 20px 24px;
            border-bottom: 1px solid #eee;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .drawer-title {
            font-size: 18px;
            font-weight: 600;
            color: #2c3e50;
        }

        .close-btn {
            background: none;
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #999;
            transition: all 0.3s ease;
        }

        .close-btn:hover {
            color: #333;
            transform: rotate(90deg);
        }

        .drawer-content {
            flex: 1;
            padding: 24px;
            overflow-y: auto;
        }

        .setting-group {
            margin-bottom: 24px;
        }

        .setting-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 16px;
            color: #2c3e50;
        }

        .setting-item {
            margin-bottom: 16px;
        }

        .setting-label {
            display: block;
            margin-bottom: 8px;
            font-size: 14px;
            color: #666;
        }

        .theme-options {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
        }

        .theme-option {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            cursor: pointer;
            border: 2px solid transparent;
            transition: all 0.3s ease;
        }

        .theme-option:hover {
            transform: scale(1.1);
        }

        .theme-option.active {
            border-color: #3498db;
            transform: scale(1.1);
        }

        .layout-options {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
        }

        .layout-option {
            padding: 12px;
            border: 2px solid #eee;
            border-radius: 8px;
            cursor: pointer;
            text-align: center;
            transition: all 0.3s ease;
        }

        .layout-option:hover {
            border-color: #3498db;
            background: #f8f9fa;
        }

        .layout-option.active {
            border-color: #3498db;
            background: #e3f2fd;
        }

        .layout-preview {
            width: 100%;
            height: 60px;
            background: #f8f9fa;
            border-radius: 4px;
            margin-bottom: 8px;
            display: flex;
        }

        .preview-sidebar {
            width: 20px;
            background: #34495e;
            border-radius: 2px 0 0 2px;
        }

        .preview-content {
            flex: 1;
            background: white;
            border-radius: 0 2px 2px 0;
        }

        .preview-header {
            height: 15px;
            background: #3498db;
            border-radius: 2px 2px 0 0;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .sidebar {
                position: fixed;
                transform: translateX(-100%);
            }
            
            .sidebar.show {
                transform: translateX(0);
            }
            
            .sidebar.collapsed {
                width: 220px;
            }
            
            .sidebar.collapsed .logo-text,
            .sidebar.collapsed .menu-text {
                opacity: 1;
                width: auto;
                margin-right: 12px;
            }
            
            .sidebar.collapsed .menu-item {
                justify-content: flex-start;
                padding: 12px 20px;
            }
            
            .sidebar.collapsed .menu-icon {
                margin-right: 15px;
            }
            
            .drawer {
                width: 100%;
            }
        }

        /* 滚动条样式 */
        ::-webkit-scrollbar {
            width: 6px;
        }

        ::-webkit-scrollbar-track {
            background: transparent;
        }

        ::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.3);
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.5);
        }
    </style>
</head>
<body>
    <!-- 主布局容器 -->
    <div class="layout-container">
        <!-- 侧边栏 -->
        <div class="sidebar" id="sidebar">
            <div class="sidebar-header">
                <div class="logo">A</div>
                <div class="logo-text">Admin Panel</div>
                <button class="toggle-btn" id="toggleSidebar">
                    <i class="fas fa-bars"></i>
                </button>
            </div>
            
            <div class="menu-list">
                <a href="#" class="menu-item active">
                    <i class="fas fa-home menu-icon"></i>
                    <span class="menu-text">仪表板</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-users menu-icon"></i>
                    <span class="menu-text">用户管理</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-chart-bar menu-icon"></i>
                    <span class="menu-text">数据分析</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-cog menu-icon"></i>
                    <span class="menu-text">系统设置</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-file-alt menu-icon"></i>
                    <span class="menu-text">文档管理</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-envelope menu-icon"></i>
                    <span class="menu-text">消息中心</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-shopping-cart menu-icon"></i>
                    <span class="menu-text">订单管理</span>
                </a>
                <a href="#" class="menu-item">
                    <i class="fas fa-question-circle menu-icon"></i>
                    <span class="menu-text">帮助中心</span>
                </a>
            </div>
        </div>

        <!-- 主内容区域 -->
        <div class="main-container">
            <!-- 头部区域 -->
            <div class="header">
                <div class="breadcrumb">
                    <span class="breadcrumb-item">首页</span>
                    <span class="breadcrumb-item">仪表板</span>
                    <span class="breadcrumb-item">概览</span>
                </div>
                
                <div class="header-actions">
                    <button class="action-btn" title="通知">
                        <i class="fas fa-bell"></i>
                    </button>
                    <button class="action-btn" title="消息">
                        <i class="fas fa-envelope"></i>
                    </button>
                    <button class="action-btn" id="openDrawer" title="设置">
                        <i class="fas fa-cog"></i>
                    </button>
                    <button class="action-btn" title="用户">
                        <i class="fas fa-user"></i>
                    </button>
                </div>
            </div>

            <!-- 内容区域 -->
            <div class="content">
                <h1 class="content-title">仪表板概览</h1>
                
                <div class="card">
                    <h2 class="card-title">系统状态</h2>
                    <p>欢迎使用后台管理系统！这是一个功能完整的管理界面布局示例。</p>
                </div>
                
                <div class="card">
                    <h2 class="card-title">数据统计</h2>
                    <p>这里可以显示各种业务数据和统计信息。</p>
                </div>
                
                <div class="card">
                    <h2 class="card-title">最近活动</h2>
                    <p>显示系统最近的操作记录和活动日志。</p>
                </div>
            </div>
        </div>
    </div>

    <!-- 抽屉遮罩层 -->
    <div class="drawer-overlay" id="drawerOverlay">
        <div class="drawer">
            <div class="drawer-header">
                <div class="drawer-title">系统设置</div>
                <button class="close-btn" id="closeDrawer">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div class="drawer-content">
                <div class="setting-group">
                    <h3 class="setting-title">主题设置</h3>
                    <div class="setting-item">
                        <label class="setting-label">选择主题颜色</label>
                        <div class="theme-options">
                            <div class="theme-option active" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);" data-theme="default"></div>
                            <div class="theme-option" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);" data-theme="pink"></div>
                            <div class="theme-option" style="background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);" data-theme="green"></div>
                            <div class="theme-option" style="background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);" data-theme="yellow"></div>
                        </div>
                    </div>
                </div>
                
                <div class="setting-group">
                    <h3 class="setting-title">布局设置</h3>
                    <div class="setting-item">
                        <label class="setting-label">选择布局模式</label>
                        <div class="layout-options">
                            <div class="layout-option active" data-layout="default">
                                <div class="layout-preview">
                                    <div class="preview-sidebar"></div>
                                    <div class="preview-content">
                                        <div class="preview-header"></div>
                                    </div>
                                </div>
                                <div>默认布局</div>
                            </div>
                            <div class="layout-option" data-layout="compact">
                                <div class="layout-preview">
                                    <div class="preview-sidebar" style="width: 15px;"></div>
                                    <div class="preview-content">
                                        <div class="preview-header" style="height: 12px;"></div>
                                    </div>
                                </div>
                                <div>紧凑布局</div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="setting-group">
                    <h3 class="setting-title">其他设置</h3>
                    <div class="setting-item">
                        <label class="setting-label">
                            <input type="checkbox" checked> 启用动画效果
                        </label>
                    </div>
                    <div class="setting-item">
                        <label class="setting-label">
                            <input type="checkbox"> 显示面包屑导航
                        </label>
                    </div>
                    <div class="setting-item">
                        <label class="setting-label">
                            <input type="checkbox" checked> 固定侧边栏
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 获取DOM元素
        const sidebar = document.getElementById('sidebar');
        const toggleSidebarBtn = document.getElementById('toggleSidebar');
        const openDrawerBtn = document.getElementById('openDrawer');
        const closeDrawerBtn = document.getElementById('closeDrawer');
        const drawerOverlay = document.getElementById('drawerOverlay');
        const themeOptions = document.querySelectorAll('.theme-option');
        const layoutOptions = document.querySelectorAll('.layout-option');

        // 切换侧边栏折叠状态
        toggleSidebarBtn.addEventListener('click', () => {
            sidebar.classList.toggle('collapsed');
            
            // 更新按钮图标
            const icon = toggleSidebarBtn.querySelector('i');
            if (sidebar.classList.contains('collapsed')) {
                icon.className = 'fas fa-arrow-right';
            } else {
                icon.className = 'fas fa-bars';
            }
        });

        // 打开抽屉
        openDrawerBtn.addEventListener('click', () => {
            drawerOverlay.classList.add('open');
            document.body.style.overflow = 'hidden'; // 防止背景滚动
        });

        // 关闭抽屉
        closeDrawerBtn.addEventListener('click', () => {
            closeDrawer();
        });

        // 点击遮罩层关闭抽屉
        drawerOverlay.addEventListener('click', (e) => {
            if (e.target === drawerOverlay) {
                closeDrawer();
            }
        });

        // ESC键关闭抽屉
        document.addEventListener('keydown', (e) => {
            if (e.key === 'Escape' && drawerOverlay.classList.contains('open')) {
                closeDrawer();
            }
        });

        // 关闭抽屉的函数
        function closeDrawer() {
            drawerOverlay.classList.remove('open');
            document.body.style.overflow = ''; // 恢复背景滚动
        }

        // 主题切换功能
        themeOptions.forEach(option => {
            option.addEventListener('click', () => {
                // 移除所有激活状态
                themeOptions.forEach(opt => opt.classList.remove('active'));
                // 激活当前选项
                option.classList.add('active');
                
                // 这里可以添加实际的主题切换逻辑
                console.log('切换到主题:', option.getAttribute('data-theme'));
            });
        });

        // 布局切换功能
        layoutOptions.forEach(option => {
            option.addEventListener('click', () => {
                // 移除所有激活状态
                layoutOptions.forEach(opt => opt.classList.remove('active'));
                // 激活当前选项
                option.classList.add('active');
                
                // 这里可以添加实际的布局切换逻辑
                console.log('切换到布局:', option.getAttribute('data-layout'));
            });
        });

        // 菜单项点击事件
        const menuItems = document.querySelectorAll('.menu-item');
        menuItems.forEach(item => {
            item.addEventListener('click', (e) => {
                e.preventDefault();
                // 移除所有激活状态
                menuItems.forEach(i => i.classList.remove('active'));
                // 激活当前项
                item.classList.add('active');
            });
        });

        // 响应式处理
        function handleResponsive() {
            if (window.innerWidth <= 768) {
                // 移动端处理
                sidebar.classList.add('collapsed');
            } else {
                // 桌面端处理
                sidebar.classList.remove('collapsed');
            }
        }

        // 页面加载时处理响应式
        window.addEventListener('load', handleResponsive);
        // 窗口大小改变时处理响应式
        window.addEventListener('resize', handleResponsive);

        // 初始化按钮图标
        if (!sidebar.classList.contains('collapsed')) {
            toggleSidebarBtn.querySelector('i').className = 'fas fa-bars';
        }
    </script>
</body>
</html>
